package com.woniu.darryringmall.front.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniu.darryringmall.front.entity.Category;
import com.woniu.darryringmall.front.entity.Goods;
import com.woniu.darryringmall.front.entity.ViewGoods;
import com.woniu.darryringmall.front.service.CategoryService;
import com.woniu.darryringmall.front.service.GoodsService;
import com.woniu.darryringmall.front.service.ViewGoodsService;
import com.woniu.darryringmall.utils.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("index")
public class IndexController {

    @Autowired
    private ViewGoodsService viewgoodsService;

    @Autowired
    private GoodsService goodsService;

    @Autowired
    private CategoryService categoryService;


    /**
     * 查询所有的钻戒类，并展示在首页
     *
     * @return
     */
    @PostMapping("category/ring")
    public ResponseData<List<Category>> ring() {
        List<Category> categories = categoryService.getList("1");
        return new ResponseData<>(categories);
    }

    /**
     * 查询所有的礼物类，并展示在首页
     *
     * @return
     */
    @PostMapping("category/gift")
    public ResponseData<List<Category>> gift() {
        List<Category> categories = categoryService.getList("2");
        return new ResponseData<>(categories);
    }

    /**
     * 查询所有的最新商品，并展示在首页
     *
     * @return
     */
    @PostMapping("newgoods")
    public ResponseData<List<Goods>> newGoods() {
        return new ResponseData<>(goodsService.newGoods());
    }

    /**
     * 查询所有的最热商品，并展示在首页
     *
     * @return
     */
    @PostMapping("hotgoods")
    public ResponseData<List<Goods>> hotGoods() {
        return new ResponseData<>(goodsService.hotGoods());
    }

}
